﻿//登录
$("#m_login_submit").click(function () {
   
    var name = $("#m_login_name").val();
    var pwd = $("#m_login_pwd").val();
    if (name.length > 0 && pwd.length > 0) { 
        $.ajax({
            type: "post", url: "/app/get_zs_web.ashx",
            data: { "por": "105", "phone": name, "userPwd": pwd, "cateid": 1 },
            async: false, dataType: "json", success: function (data) {
                if (data.code == 1) {
                    window.location.href = "m_active.html";
                } else { $("#m_login_note").html(data.msg); }
            }
        });
    } else { $("#m_login_note").html("手机号和密码不能为空"); }
});

//注册
$("#btn_login").click(function () {

    var name = $("#m_reg_name").val();
    var pwd = $("#m_reg_pwd").val();
    var code = $("#m_reg_code").val();
    var nickname = $("#m_reg_nickname").val();
    var cate = $(".ul_box .selectLi").attr("data-val"); 
    if (Validate_phone(name) == true) {
        if (name.length > 0 && pwd.length > 0 && code.length > 0 && nickname.length>0) {
            $.ajax({
                type: "post", url: "/app/get_zs_web.ashx",
                data: { "por": 104, "phone": name, "pwd": pwd, "code": code, "nickname": nickname, "cateid": cate },
                async: false, dataType: "json", success: function (data) {
                    if (data.code == 1) {
                        alert("注册成功");
                        window.location.href = "m_active.html";

                    } else { $("#m_reg_note").html(data.msg); }
                }
            });
        } else { $("#m_reg_note").html("请填全所有项"); }
    } else { $("#m_reg_note").html("手机号格式不正确"); }
});

//获取效验码
$("#m_send_code").click(function () {
    var phone = $("#m_reg_name").val();
    if (Validate_phone(phone) == true) {
        $.ajax({
            type: "post", url: "/app/get_zs_web.ashx",
            data: { "por": 1031, "phone": phone },
            async: false, dataType: "json", success: function (data) {
                if (data.code == 1) {


                } else { $("#m_reg_note").html(data.msg); }
            }
        });
    } else { $("#m_reg_note").html("手机号格式不正确"); }
});
//修改密码获取效验码
$("#m_send_code").click(function () {
    var phone = $("#m_reg_name").val();
    if (Validate_phone(phone) == true) {
        $.ajax({
            type: "post", url: "/app/get_zs_web.ashx",
            data: { "por": 1032, "phone": phone },
            async: false, dataType: "json", success: function (data) {
                if (data.code == 1) {


                } else { $("#m_reg_note").html(data.msg); }
            }
        });
    } else { $("#m_reg_note").html("手机号格式不正确"); }
});

//修改密码 -下一步
$("#btn_xia").click(function () {

    var phone = $("#m_reg_name").val();
    var code = $("#m_reg_code").val();
    if (Validate_phone(phone) == true) {
        if (code.length>0) {
        $.ajax({
            type: "post", url: "/app/get_zs_web.ashx",
            data: { "por": 1033, "phone": phone, "code": code },
            async: false, dataType: "json", success: function (data) {
                if (data.code == 1) {
                    $("#up_pwd_val").val(1);
                } else { alert(data.msg); }
            }
        });
        } else { $("#m_reg_note").html("效验码不能为空"); }
    } else { $("#m_reg_note").html("手机号格式不正确"); }

})


//修改密码 -上一步
$("#new_pwd_save").click(function () {

    var phone = $("#m_reg_name").val();
    var code = $("#m_reg_code").val();
    var newPwd = $("#m_new_pwd").val();
    var newPwd2 = $("#m_new_pwd2").val();
    if (newPwd == newPwd2 && newPwd.length>0) {
        $.ajax({
            type: "post", url: "/app/get_zs_web.ashx",
            data: { "por": "136", "phone": phone, "code": code, "pwd": newPwd },
            async: false, dataType: "json", success: function (data) {
                if (data.code == 1) {
                    window.location.href = "m_myProject.html";
                } else { $("#m_reg_note").html(data.msg); }
            }
        });
    } else { $("#m_reg_note").html("两次密码输入不一致"); }

})